$(function () {
    $("#add-board-btn").click(function (event) {
        event.preventDefault();
        zlalert.alertOneInput({
            'text':'请输入版块名称！',
            'placeholder':'版块名称',
            'confirmCallback':function (inputValue) {
                zlajax.post({
                    'url':'/cms/aboard/',
                    'data':{
                        'name':inputValue
                    },
                    'success':function (data) {
                        if(data['code'] == 200){
                            window.location.reload();
                        }else{
                            zlalert.alertInfo(data['message']);
                        }
                    }
                });
            }
        });
    });
});

$(function () {
    $(".edit-banner-btn").click(function (event) {
        var self = $(this);
        var tr = self.parent().parent();
        var board_id = tr.attr('data-id')
        var name = tr.attr('data-name')

        zlalert.alertOneInput({
            'text':'请输入新版块名称',
            'placeholder':name,
            'confirmCallback':function (inputValue) {
                zlajax.post({
                    'url':'/cms/uboard/',
                    'data':{
                        'name':inputValue,
                        'board_id':board_id
                    },
                    'success':function (data) {
                        if(data['code'] == 200){
                            window.location.reload();
                        }else{
                            zlalert.alertInfo(data['message'])
                        }
                    }
                });
            }
        });
    });

});

$(function () {
    $(".delete-banner-btn").click(function (event) {
        var self = $(this);
        var tr = self.parent().parent();
        var board_id = tr.attr('data-id');
        zlalert.alertConfirm({
            'msg':'你确定要删除这个版块吗？',
            'confirmCallback':function(){
                zlajax.post({
                    'url':'/cms/dboard/',
                    'data':{
                        'board_id':board_id
                    },
                    'success':function (data) {
                        if(data['code'] == 200){
                            window.location.reload();
                        }else{
                            zlalert.alertInfo(data['message']);
                        }
                    }
                });
            }
        });
    });
});